const WebSocket = require('ws')

var websocket = new WebSocket("ws://zhizhemodi.tech:10110/websocket/1")

websocket.onopen = function() {
    console.log("连接成功")
}

websocket.onclose = function(){
    console.log("退出连接");
}

websocket.onmessage = function (event){
    console.log("收到消息"+event.data);
}

websocket.onerror = function(){
    console.log("连接出错");
}

websocket.onbeforeunload = function () {
    websocket.close(num);
}